package com.andong.controller;

import com.andong.annotations.AccessControl;
import com.andong.domain.entity.ChooseCoach;
import com.andong.domain.pojo.Result;
import com.andong.service.ChooseCoachService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import static com.andong.utils.SystemConstant.*;

/**
 * 教练选择表(ChooseCoach)表控制层
 *
 * @author makejava
 * @since 2024-03-20 17:56:12
 */
@RestController
@RequestMapping("/chooseCoach")
public class ChooseCoachController {
    /**
     * 服务对象
     */
    @Resource
    private ChooseCoachService chooseCoachService;

    @PostMapping
    @AccessControl(roles = STUDENT)
    public Result insert(@RequestBody ChooseCoach chooseCoach) {
        return chooseCoachService.insert(chooseCoach);
    }

    @PutMapping()
    @AccessControl(roles = COACH)
    public Result update(@RequestBody ChooseCoach chooseCoach) {
        return chooseCoachService.modify(chooseCoach);
    }

    @GetMapping("/student/{id}")
    public Result selectByStudentId(@PathVariable Long id) {
        return chooseCoachService.selectByStudentId(id);
    }

    @GetMapping("/coach/{id}")
    public Result selectByCoachId(@PathVariable Long id) {
        return chooseCoachService.selectByCoachId(id);
    }
}

